package com.ideaplugin.datamanager.controller;

import com.ideaplugin.datamanager.model.common.ListResult;
import com.ideaplugin.datamanager.model.common.PlainResult;
import com.ideaplugin.datamanager.model.request.RoleColumnParam;
import com.ideaplugin.datamanager.model.request.TableColumnParam;
import com.ideaplugin.datamanager.model.request.TableColumnSortParam;
import com.ideaplugin.datamanager.model.response.TableColumnVo;
import com.ideaplugin.datamanager.service.TableColumnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhaojingbo
 * @since 2023-06-07
 */
@RestController
@RequestMapping("/tableColumn")
public class TableColumnController {

    @Autowired
    private TableColumnService tableColumnService;


    @GetMapping("/list")
    public ListResult<TableColumnVo> list(Long param) {
        return new ListResult<>(tableColumnService.list(param));
    }

    @GetMapping("/delete")
    public PlainResult<Boolean> delete(Long param) {
        return new PlainResult<>(tableColumnService.delete(param));
    }

    @PostMapping("/saveOrUpdate")
    public PlainResult<Boolean> saveOrUpdate(@RequestBody TableColumnParam param) {
        return new PlainResult<>(tableColumnService.saveOrUpdate(param));
    }

    @PostMapping("/listRoleColumnCode")
    public ListResult<String> listRoleColumnCode(@RequestBody RoleColumnParam param) {
        return new ListResult<>(tableColumnService.listRoleColumnCode(param));
    }

    @PostMapping("/sortTableColumn")
    public PlainResult<Boolean> sortTableColumn(@RequestBody TableColumnSortParam param) {
        return new PlainResult<>(tableColumnService.sortTableColumn(param));
    }

}
